Use RStudio projects!
scripts/data/In scripts/ folder:
scripts/input.R - download and gather datascripts/tidy.R - process data into usable by model stepscripts/model.R - create modelsscripts/out.R - make plots, Rmd, final outputsIn data/ folder:
data/raw/ - any raw data files (CSVs etc)data/cache/ - API cache filesdata/output/ - clean tidy filesUse saveRDS/readRDS rather than write.csv()/read.csv() - 10xquicker
decomp_ga$data_f = function to get datadecomp_ga$model_f = function to model datadecomp_ga$output_f = function to plot data## function(df, ...){
## decompose(ts(df$sessions, frequency = 7))
## }
ga_model_make().gamr objectA bit out of date!
library(shiny)
library(googleAuthR)
library(googleAnalyticsR)
ui <- fluidPage(
titlePanel("ga_model Shiny Demo"),
authDropdownUI("picker"),
)
server <- function(input, output, session) {
gar_shiny_auth(session)
viewId <- callModule(authDropdown, "picker",
ga.table = reactive(ga_account_list()))
}
# Run the application
shinyApp(ui = gar_shiny_ui(ui), server = server)library(shiny)
library(googleAnalyticsR)
library(googleAuthR)
decomp_ga <- ga_model_example("decomp_ga.gamr")
shiny_model <- ga_model_edit(decomp_ga,
outputShiny = plotOutput,
renderShiny = renderPlot)
ui <- fluidPage(
titlePanel("ga_model Shiny Demo"),
authDropdownUI("picker"),
shiny_model$shiny_module$ui("model1")
)
server <- function(input, output, session) {
gar_shiny_auth(session)
viewId <- callModule(authDropdown, "picker",
ga.table = reactive(ga_account_list()))
callModule(shiny_model$shiny_module$server, "model1",
view_id = viewId)
}
# Run the application
shinyApp(ui = gar_shiny_ui(ui), server = server)